import cv2
import sys
import numpy as np
import time
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import *
import win32gui
import sys

def get_screen():
    hwnd = win32gui.FindWindow(0, 'Lost Castle')
    app = QApplication(sys.argv)
    screen = QApplication.primaryScreen()
    img = screen.grabWindow(hwnd).toImage()
    img.save("temp.jpg")
    time.sleep(0.01)
    img = cv2.imread('temp.jpg',cv2.IMREAD_GRAYSCALE)
    screen = cv2.resize(img,(120,100))
    screen = cv2.cvtColor(screen, cv2.COLOR_BGR2RGB)
    screen = screen[40:80]
    return screen